<template>
	<view class="container">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="待受理" back-icon-color='#333333' height="50" :border-bottom="false">
		</u-navbar>
		<u-mask :show="display">
			<view class="warp">
				<view class="rect" @tap.stop>
					<view class="tanchu">
						确认取消申请?
					</view>
					<view class="anniu">
						<view class="" @click="display=false">
							取消
						</view>
						<view class="" @click="repairDelete">
							确定
						</view>
					</view>
				</view>
			</view>
		</u-mask>
		<view class="list">
			<view class="repair_number">
				<text>报修编号:</text>
				<text>{{maintenance_id}}</text>
			</view>
			<view class="category">
				<text>类别</text>
				<text>{{maintenance_type}}</text>
			</view>
			<view class="matter">
				<text>内容</text>
				<text>{{maintenance_content}}</text>
			</view>
			<view class="location">
				<text>位置</text>
				<text>{{maintenance_address}}</text>
			</view>
			<view class="applicant">
				<text>申请人</text>
				<text>{{maintenance_name}}</text>
			</view>
			<view class="remarks">
				<text>申请人备注</text>
				<text>{{maintenance_remark}}</text>
			</view>
			<view class="accessory">
				<text>附件</text>
			</view>
			<!-- 	<view class="picture">
				<image src="../../static/tupian102.png" mode="widthFix"></image>
				<image src="../../static/tupian102.png" mode="widthFix"></image>
			</view> -->
			<view class="" style="width:710rpx; height:30rpx; margin-left:20rpx; border-bottom: 1rpx solid #F2F2F2;">
			</view>
			<view class="submit">
				<text>提交时间</text>
				<text>{{maintenance_time}}</text>
			</view>
			<view class="status">
				<text>状态</text>
				<text>{{maintenance_status}}</text>
			</view>
			<view class="receiver">
				<text>受理人</text>
				<text>{{maintenance_person}}</text>
			</view>
			<view class="process">
				<text>受理时间</text>
				<text>{{process_time}}</text>
			</view>
			<view class="acceptor">
				<text>受理人备注</text>
				<text>{{maintenance_note}}</text>
			</view>
			<view class="" style="width:100%; height:25rpx;background:#fff;">

			</view>
		</view>
		<view class="confirm">
			<view class="cancel" @click="display=true">
				{{cancel}}
			</view>
			<view class="verify" @click="nvigate_path">
				{{verify}}
			</view>

		</view>
	</view>
</template>

<script>
	import request from '../../request.js'
	import time from '../../time.js'
	export default {
		data() {
			return {
				dataList: [],
				input_content: '',
				maintenance_type: '',
				maintenance_id: '',
				maintenance_content: '',
				maintenance_address: '',
				maintenance_name: '',
				maintenance_remark: '',
				maintenance_time: '',
				maintenance_status: '',
				maintenance_person: '',
				process_time: '',
				maintenance_note: '',
				cancel: '取消申请',
				verify: '修改',
				display: false,
				delivery_obj: {},
				repair_id: '',
			}
		},
		onLoad(option) {
			if (option.id) {
				this.repair_id = option.id;
			}
			this.repairInfo();
		},
		methods: {
			repairDelete() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				this.display = false;
				let _this = this;
				request({
					url: base_url + 'general/repair/delete',
					method: 'post',
					data: {
						repair_id: this.repair_id,
					},
					success(res) {
						if (res.statusCode == 200) {
							_this.$toLink('../maintenance/maintenance', {})
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
			nvigate_path() {
				if(this.repair_id){
					this.$toLink('../add_maintenance/add_maintenance', {
						repairId: this.repair_id
					})
				}
			},
			repairInfo() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				this.display = false;
				let _this = this;
				request({
					url: base_url + 'teacher/repair/repairInfo',
					method: 'post',
					data: {
						repair_id: this.repair_id ? this.repair_id : 1,
					},
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data.data);
							_this.maintenance_id = res.data.data.repair_id;
							_this.maintenance_remark = res.data.data.remark;
							_this.maintenance_time = time.format(res.data.data.create_time);
							_this.maintenance_address = res.data.data.room_info ? res.data.data.room_info[0].name :
								'';
							switch (res.data.data.status) {
								case 1:
									_this.maintenance_status = '待处理';
									break;
								case 2:
									_this.maintenance_status = '同意';
									break;
								case 3:
									_this.maintenance_status = '拒绝';
									break;
							}
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
		},
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		height: 100vh;
		background-color: #F2F2F2;
		overflow: hidden;

		.warp {
			display: flex;
			align-items: flex-start;
			justify-content: center;
			height: 100%;

			.rect {
				margin-top: 450rpx;
				border-radius: 10rpx;
				width: 480rpx;
				height: 250rpx;
				background-color: #fff;

				.tanchu {
					width: 100%;
					height: 150rpx;
					font-size: 33rpx;
					color: #3E3E3E;
					text-align: center;
					line-height: 150rpx;
				}

				.anniu {
					width: 100%;
					height: 100rpx;
					display: flex;
					justify-content: space-around;
					align-items: center;

					view {
						border-radius: 30rpx;
						width: 150rpx;
						height: 60rpx;
						text-align: center;
						line-height: 60rpx;
						font-size: 26rpx;

						&:nth-child(1) {
							color: #2C78FE;
							margin-left: 15rpx;
							border: 1px solid #2C78FE;
							background: #fff;

						}

						&:nth-child(2) {
							color: #fff;
							margin-right: 15rpx;
							background: linear-gradient(to right, #2C78FE, #32B0FF);
						}


					}
				}
			}
		}

		.list {
			width: 100%;
			background: #fff;
			overflow: hidden;
			margin-top: 20rpx;

			.repair_number {
				width: 710rpx;
				margin-left: 20rpx;
				height: 90rpx;
				display: flex;
				justify-content: flex-start;
				background: #fff;
				align-items: center;
				border-bottom: 1rpx solid #F2F2F2;

				text {
					font-size: 30rpx;
					color: #333333;

					&:nth-child(1) {
						width: 150rpx;
					}
				}
			}

			.category {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;

					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.matter {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;

					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.location {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.applicant {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.remarks {
				width: 710rpx;
				margin-left: 20rpx;
				height: 85rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.accessory {
				width: 710rpx;
				margin-left: 20rpx;
				height: 80rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.picture {
				width: 710rpx;
				display: flex;
				justify-content: flex-start;
				flex-wrap: wrap;
				margin-left: 20rpx;

				image {
					width: 155rpx;

					&:nth-child(n+1) {
						margin-left: 25rpx;
					}

					&:nth-child(1) {
						margin-left: 0rpx;
					}
				}


			}

			.submit {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
						width: 300rpx;
					}
				}
			}

			.status {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
						width: 160rpx;
					}
				}
			}

			.receiver {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
						width: 160rpx;
					}
				}
			}

			.process {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
						width: 160rpx;
					}
				}
			}

			.acceptor {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #777777;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
						width: 160rpx;
					}
				}
			}
		}

		.confirm {
			width: 100%;
			height: 200rpx;
			display: flex;
			justify-content: space-around;
			align-items: center;

			.verify {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx;
				text-align: center;
				line-height: 60rpx;
				background: linear-gradient(to right, #2C78FE, #32B0FF);
				color: #fff;
				font-size: 30rpx;
			}

			.cancel {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx;
				text-align: center;
				line-height: 60rpx;
				background: #fff;
				color: #666666;
				font-size: 30rpx;
			}
		}
	}
</style>
